#version 460
#extension GL_GOOGLE_include_directive : enable

//#include "../../../../core/shader_taster_color.h"
#include "../../../../core/shader_binding_ID.h"


layout(triangles) in;
layout(triangle_strip, max_vertices=3) out;


layout(location = 0) in vec4 vColor[];
layout(location = 1) in vec3 vNormal[];
layout(location = 2) in vec3 vLightPos[][4];
layout(location = 6) in float vDepthScale[];
layout(location = DEF_BINDING_LocationBindID_Vert) in vec3 vVert[];
layout(location = DEF_BINDING_LocationBindID_RotMat) in mat3x3 vRotMat[];

in gl_PerVertex {
	vec4 gl_Position;
	float gl_PointSize;
}gl_in[];


layout(location = 0) out vec4 outColor;
layout(location = 1) out vec3 outNormal;
layout(location = 2) out vec3 outLightPos[4];
layout(location = 6) out float outDepthScale;

out gl_PerVertex {
	vec4	gl_Position;
};






void main(void){
	vec3 edgeA = normalize(vVert[1] - vVert[0]);
	vec3 edgeB = normalize(vVert[2] - vVert[0]);
	
	vec3 Normal = cross(edgeA, edgeB);
	float depth = vDepthScale[0];
	//depth = 0.01;
	for(int i=0; i<3; ++i){
		//uint id = i;
		outNormal = Normal;
		outDepthScale = depth;

		outColor = vColor[i];
		outColor.a = 1;
		gl_Position = gl_in[i].gl_Position;
		outLightPos[0] = vLightPos[i][0];
		outLightPos[1] = vLightPos[i][1];
		outLightPos[2] = vLightPos[i][2];
		outLightPos[3] = vLightPos[i][3];
		
		EmitVertex();
	}

	EndPrimitive();
}



